package fr.upstlse.glre.client.espaceperso;

import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.custom.ThemeSelector;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FillLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;

import fr.upstlse.glre.client.espacededie.AbstractEspaceDebie;
import fr.upstlse.glre.client.espaceperso.component.CenterPanel;
import fr.upstlse.glre.client.espaceperso.component.NorthPanel;
import fr.upstlse.glre.client.espaceperso.component.WestPanel;
import fr.upstlse.glre.client.utilitaires.ControlerUtil;
import fr.upstlse.glre.client.vo.user.EtudiantVOGWT;

public class EspaceEtudiant extends AbstractEspaceDebie<EtudiantVOGWT> {



	private ContentPanel westPanel;
	private ContentPanel centerPanel;
	
	private static EspaceEtudiant instance;

	public ContentPanel getWestPanel() {
		return westPanel;
	}


	public void setWestPanel(ContentPanel westPanel) {
		this.westPanel = westPanel;
	}



	public ContentPanel getCenterPanel() {
		return centerPanel;
	}



	public void setCenterPanel(ContentPanel centerPanel) {
		this.centerPanel = centerPanel;
	}

	public static EspaceEtudiant getInstance() {
		if(instance == null) {
			instance = new EspaceEtudiant();
		}
		return instance;
	}

	public static void setInstance(EspaceEtudiant instance) {
		EspaceEtudiant.instance = instance;
	}

	protected void createComponents() {
		//viewport.setData("layout", new FitLayout());
		viewport.setLayout(new BorderLayout());

		
		BorderLayoutData lNorthBorderLayoutData = new BorderLayoutData(LayoutRegion.NORTH, 80);
		BorderLayoutData lWestBorderLayoutData = new BorderLayoutData(LayoutRegion.WEST, 200);
		BorderLayoutData lCenterBorderLayoutData = new BorderLayoutData(LayoutRegion.CENTER);
		centerPanel = new ContentPanel();
		centerPanel.getHeader().addTool(new ThemeSelector());
		centerPanel.setLayout(new FillLayout());
		CenterPanel lCenterPanel = CenterPanel.getInstance();
		lCenterPanel.initWidget();
		centerPanel.add(lCenterPanel);
//		CenterPanel.addProfil();


		NorthPanel lNorthPanel = new NorthPanel();
		lNorthPanel.initWidget();
		viewport.add(lNorthPanel, lNorthBorderLayoutData);
		
		WestPanel lWestPanel = new WestPanel();
		lWestPanel.initWidget();
		viewport.add(lWestPanel, lWestBorderLayoutData);
		viewport.add(centerPanel, lCenterBorderLayoutData);
		viewport.layout();


//		viewport.hideLoadingPanel("loading");
	}



	public void getUserInformation(long lId) {
		ControlerUtil.getUserControlerServiceAsyncInstance().getEtudiantById(
				lId, getUserInformationAsyncCallBack());
	}
	
	public static void killInstance() {
		CenterPanel.killInstance();
		instance = null;
	}

}